package com.zhiyou100.service;
import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou100.dao.ProjectDao;
import com.zhiyou100.model.Progress;
import com.zhiyou100.model.Project;
import com.zhiyou100.service.ProjectService;
import com.zhiyou100.vo.PageVo;
import com.zhiyou100.vo.ProjectList;

@Service
public class ProjectServiceImpl implements ProjectService {

	@Autowired
	private ProjectDao projectDao;
	
	
	//根据项目id获取项目详情
	@Override
	public Project getProjectById(int id) {
		// TODO Auto-generated method stub
		
		return projectDao.getProjectById(id);
	}

	//添加项目
	@Override
	public void saveProject(Project project) {
		// TODO Auto-generated method stub

		projectDao.saveProject(project);
		
	}

	//审核项目，根据项目的id更改项目的状态status字段
	@Override
	public void updateStatusByProjectId(int projectId, int status) {
		// TODO Auto-generated method stub

		projectDao.updateStatusByProjectId(projectId, status);
		
	}

	//根据项目id更新项目详情
	@Override
	public void updateProject(Project project) {
		// TODO Auto-generated method stub
		projectDao.updateProject(project);
	}

	//添加    项目更新表的信息，要和上面的项目id 联系到一块	
	@Override
	public void saveUpdateProject(Progress progress) {
		// TODO Auto-generated method stub
		
		projectDao.saveUpdateProject(progress);
	}

	//根据项目id，删除项目
	@Override
	public void deleteProjectByProjectId(int projectId) {
		// TODO Auto-generated method stub
		
		projectDao.deleteProjectByProjectId(projectId);
	}

	@Override
	public ProjectList<Project> findAll(Integer categoryId, Integer status, Integer order) {
		// TODO Auto-generated method stub
	 
		ArrayList<Project> projects =	projectDao.findAllByCategoryOrStatus(categoryId, status, order);

		return new ProjectList<Project>(projects);
	}

}
